package jzqb.service.impl;


import haha.life.normal.TokenUtils;
import jzqb.dao.AdminCheckPermissionsDao;
import jzqb.po.AdminDepartmentPo;
import jzqb.service.AdminCheckPermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class AdminCheckPermissionsServiceImpl implements AdminCheckPermissionsService {

    @Autowired
    private AdminCheckPermissionsDao adminCheckPermissionsDao;

//    @Override
//    public Boolean checkPermissions(HttpServletRequest request, String[] permissionTypeList){
//        return adminCheckPermissionsDao.checkPermissions(request,permissionTypeList);
//    }

    @Override
    public Boolean inPermissionGroup(HttpServletRequest request, String[] permissionGroupList) {
        return adminCheckPermissionsDao.inPermissionGroup(request, permissionGroupList);
    }

    ;

    @Override
    public Boolean inPermissionGroup_Total(HttpServletRequest request, String[] permissionGroupList) {
        return adminCheckPermissionsDao.inPermissionGroup_Total(request, permissionGroupList);
    }

    ;

    @Override
    public Boolean isDeptLeader(HttpServletRequest request) {
        String token = request.getHeader("token");
        String userID = TokenUtils.checkTokenReturnID(token);
        List<AdminDepartmentPo> leadDeptLis = adminCheckPermissionsDao.findLeadDeptLis(userID);
        if (leadDeptLis == null || leadDeptLis.isEmpty()) {//为空
            return false;
        } else {
            return true;
        }
    }

    @Override
    public boolean showSelfBaseButton(String userid) {
        return adminCheckPermissionsDao.showSelfBaseButton(userid);
    }
}
